package com.lcu.wl.modules.sys.controller;

import com.lcu.wl.modules.sys.entity.User;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *公共组件
 */
public abstract class AbstractController {
    protected Logger logger = LoggerFactory.getLogger(getClass());

    /**
     * 获取当前登录的用户
     * @return  User
     */
    protected User getUser(){
        return (User) SecurityUtils.getSubject().getPrincipal();
    }

    /**
     * 获取当前登录用户的ID
     * @return  Long
     */
    protected Long getUserId(){
        return getUser().getUserId();
    }

    /**
     * 获取当前登录用户名
     * @return
     */
    protected String getUserName(){
        return getUser().getUsername();
    }
}
